#ifndef _DEFINE_DX_H_
#define _DEFINE_DX_H_

#include "DXUT.h"
#include "DXUTcamera.h"
#include "DXUTgui.h"
#include "DXUTsettingsDlg.h"
#include "SDKmisc.h"

#include "./../resource.h"

// my types and definitions
#include "./../../aurora/visual/visual.h"
using namespace Holders;
using namespace Except;
using namespace Mathematics;
using namespace Matrix;
using namespace Geometry;

const float default_tesselation_factor = 10.0;
const int qttPt = 5;
const int limitTime = 10;

namespace ShaderSpace {

	// Partition mode
	enum E_PARTITION_MODE {
		PARTITION_INTEGER,
		PARTITION_FRACTIONAL_EVEN,
		PARTITION_FRACTIONAL_ODD
	};

//	typedef E_PARTITION_MODE PARTITION_MODE;

	//--------------------------------------------------------------------------------------
	// UI control IDs //as enum, they have meaning and a common type
	//--------------------------------------------------------------------------------------
	enum IDC {
		IDC_TOGGLEFULLSCREEN = 1,
		IDC_TOGGLEREF = 3,
		IDC_CHANGEDEVICE = 4,
		IDC_PATCH_SUBDIVS = 5,
		IDC_PATCH_SUBDIVS_STATIC = 6,
		IDC_TOGGLE_LINES = 7,
		IDC_PARTITION_MODE = 8,
		IDC_PARTITION_INTEGER = 9,
		IDC_PARTITION_FRAC_EVEN = 10,
		IDC_PARTITION_FRAC_ODD = 11,
		IDC_SURFACE_SELECTION = 12,
		IDC_TIME_POSITION = 13,
		IDC_TIME_POSITION_STATIC_TEXT = 14,
		IDC_TIME_ANIM = 15,
		IDC_TIME_INTERPOL = 16
	};

	string& operator += ( string &str, const IDC &obj );

	inline string operator + ( const string &str, const IDC &obj ) {
		string result = str;
		return result += obj;
	};

	inline string operator + ( const IDC &obj, const string &str ) {
		return string("") + obj + str;
	};

	inline ostream& operator << ( ostream &out, const IDC &obj ) {
		return out << ( string("") + obj );
	};

	//D3D11_USAGE;

	string& operator += ( string &str, const D3D11_USAGE &obj );

	inline string operator + ( const string &str, const D3D11_USAGE &obj ) {
		string result = str;
		return result += obj;
	};

	inline string operator + ( const D3D11_USAGE &obj, const string &str ) {
		return string("") + obj + str;
	};

	inline ostream& operator << ( ostream &out, const D3D11_USAGE &obj ) {
		return out << ( string("") + obj );
	};

	//D3D11_BIND_FLAG;

	string& operator += ( string &str, const D3D11_BIND_FLAG &obj );

	inline string operator + ( const string &str, const D3D11_BIND_FLAG &obj ) {
		string result = str;
		return result += obj;
	};

	inline string operator + ( const D3D11_BIND_FLAG &obj, const string &str ) {
		return string("") + obj + str;
	};

	inline ostream& operator << ( ostream &out, const D3D11_BIND_FLAG &obj ) {
		return out << ( string("") + obj );
	};

	//D3D11_CPU_ACCESS_FLAG;

	string& operator += ( string &str, const D3D11_CPU_ACCESS_FLAG &obj );

	inline string operator + ( const string &str, const D3D11_CPU_ACCESS_FLAG &obj ) {
		string result = str;
		return result += obj;
	};

	inline string operator + ( const D3D11_CPU_ACCESS_FLAG &obj, const string &str ) {
		return string("") + obj + str;
	};

	inline ostream& operator << ( ostream &out, const D3D11_CPU_ACCESS_FLAG &obj ) {
		return out << ( string("") + obj );
	};

};

// MEMO - pointer have to be allocated before used!
// MEMO - Type* &obj - works with the original pointer, not a copy!

// TODO - use these definitions!
template < class Type >
	inline bool CreatePointerAllocation( Type* &pointer, const usint number_of_objects = 1 ) {
		pointer = (Type*) malloc( number_of_objects * sizeof( Type ) );
		return pointer != NULL;
	};

template< class Type >
	inline void SafeDelete( Type* &obj ) {
		if( obj != NULL ) {
			delete obj;
			obj = NULL;
		}
	};

#endif // _DEFINE_DX_H_
